#include "VectorLayerProperty.h"
#include "VectorLayer.h"
#include <QColorDialog>

VectorLayerProperty::VectorLayerProperty(VectorLayer* vectorLayer, QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	ui.txtDataSource->setText(vectorLayer->getFilePath());
	setPushButtonColor(ui.btnChangeColor, vectorLayer->getBoundaryColor());

	_selectedColor = vectorLayer->getBoundaryColor();
	connect(ui.btnChangeColor, SIGNAL(clicked()), this, SLOT(selectColor()));
}

VectorLayerProperty::~VectorLayerProperty()
{

}

void VectorLayerProperty::selectColor()
{
	QColor color =  QColorDialog::getColor();
	if(!color.isValid()) return;
	_selectedColor = color;
	setPushButtonColor(ui.btnChangeColor, color);
}

void VectorLayerProperty::setPushButtonColor( QPushButton* button, QColor color )
{
	QString strColor = "rgb(" + QString::number(color.red()) + "," +
								QString::number(color.green()) + "," +
								QString::number(color.blue()) + ");";

	button->setStyleSheet("background-color: " + strColor);
}
